﻿using Sasc.PV.Common;
using Sasc.PV.DAL;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Management;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sasc.PV.Web
{
    public partial class Activate : PVPage
    {
        protected void Page_Load(object sender, EventArgs e)
        { 
            Page.Title = WebUtils.SystemName;

            if (!Page.IsPostBack)
            {
                this.TextBoxMachineCode.Text = Utils.GetMacAddress();
            }
        }
         
        protected void ButtonSerial_Click(object sender, EventArgs e)
        {
            try
            {
                new ERPSerils().UpdateSerils(this.TextBoxAuthCode.Text.Trim().Split('-')[0],
                                             this.TextBoxAuthCode.Text.Trim().Split('-')[1],
                                             this.TextBoxAuthCode.Text.Trim().Split('-')[2],
                                             this.TextBoxAuthCode.Text.Trim().Split('-')[3]);
                MessageBox.ShowAndRedirect(this, "系统授权码已经写入完毕！", WebUtils.MakeRelative(WebUtils.DefaultPageURL));
            }
            catch
            {
                MessageBox.ShowAndRedirect(this, "系统授权码写入时发生错误！请重新获取！", WebUtils.MakeRelative(WebUtils.ActivatePageURL));
            }
        }

    }
}